import 'dart:convert';

import '../../../utils/http_util.dart';
import 'models/MovieItem.dart';

class HomeRequest {
  static Future<List<MovieItem>> getMovieList(int start, int count) async {
    final movieUrl = "movie/top250?start=$start&count=$count";
    print(movieUrl);
    final result = await HttpUtil.request(movieUrl);

    // 电影
    final subjects = jsonDecode(result)["subjects"];

    List<MovieItem> movies = [];
    for (var sub in subjects) {
      movies.add(MovieItem.fromMap(sub));
    }
    return movies;
  }
}
